<template>
    <div :class="{ 'header':true, 'fade-in':show || $route.path.includes('/about') }" @mouseenter="show = true" @mouseleave="show = false">
        <div class="header-icon">
            <div class="line"></div>
            <div class="text">能源 安防 环境 运维<br/>智慧工业集成商</div>
        </div>
        <div class="menu">
            <div
                v-for="item in menuList"
                :key="item.path"
                :class="{ 'menu-item':true, 'selected':$route.matched.length > 2 ? $route.matched[1].path === item.path : $route.path === item.path }"
                @click="()=>handleClick(item.path)"
            >
                <span>{{  item.title }}</span>
            </div>
        </div>
        <div class="entry">
            <span style="margin-right:16px; cursor:pointer; " @click="handleGo">进入厂务</span>
            <el-icon color="#fff" size="24px" style="font-weight:bold;"><Right /></el-icon>
        </div>
    </div>
</template>

<script setup> 
    import { markAction } from '@/api/global.js';
    import { ref } from 'vue';
    import { useRouter } from 'vue-router';
    import { Right } from '@element-plus/icons-vue';
    const show = ref(false);
    const router = useRouter();
    const menuList = [
        { title:'首页', path:'/home' }, { title:'产品中心', path:'/product'}, { title:'成功案例', path:'/case' },
        { title:'生态合作', path:'/teamwork' }, { title:'开放平台', path:'/platform' }, { title:'关于我们', path:'/about' } 
    ];
    const handleClick = ( path )=>{
        if ( path === '/platform') {
            markAction({ operationType:'进入开放平台' });
            window.open('http://open.ifmcs.com', '__blank');
        } else {
            router.push(path);
        }
    }
    const handleGo = ()=>{
        markAction({ operationType:'进入厂务' });
        window.open('http://iot.ifmcs.com', '__blank');
    }
</script>
<style>
.header {
    width:100%;
    height:80px;
    position:fixed;
    top:0;
    left:0;
    display:flex;
    padding-left:40px;
    align-items: center;
    background:transparent;
    border-bottom:1px solid rgba(255, 255, 255, 0.29); 
    justify-content: space-between;
    z-index:100;
    transition:background 0.3s ease-in;
}

.entry {
    width:160px;
    height:100%;
    display:flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color:#fff;
    background:transparent;
    border-left:1px solid rgba(255, 255, 255, 0.29); 
    transition:all 0.3s ease-in;
}
.menu {
    display:flex;
    align-items: center;
    /* transition: all 0.3s; */
}
.menu .menu-item {
    height:20px;
    line-height:20px;
    margin:0 40px;
    color:rgba(255, 255, 255, 0.6);
    font-weight:lighter;
    cursor: pointer;
    transition:all 0.3s ease-in;
}
.menu .menu-item.selected {
    color:#fff;
}
.header-icon {
    width:138px;
    height:36px;
    background-image:url('../../../public/logo_white.png');
    background-repeat: no-repeat;
    background-size: contain;
    position:relative;
}
.header-icon .line {
    position:absolute;
    top:0;
    right:-16px;
    width:1px;
    height:100%;
    background: #d9d9d9;
}
.header-icon .text {
    position:absolute;
    top:0;
    right:-156px;
    line-height:20px;
    color:rgba(255, 255, 255, 0.6);
}
.app-container.show-menu .header, .header.fade-in {
    background:rgba(255, 255, 255, 0.8);
    box-shadow:0px 2px 8px #00000012;
    border-bottom:none;
    backdrop-filter:saturate(180%) blur(20px);
}
.app-container.show-menu .menu-item, .header.fade-in .menu-item {
    color:#99A0AE;
}
.app-container.show-menu .menu-item.selected, .header.fade-in .menu-item.selected {
    color:#335CFF;
}
.app-container.show-menu .header-icon .text, .header.fade-in .header-icon .text {
    color:#525866;
}
.app-container.show-menu .entry, .header.fade-in .entry {
    background:#335CFF;
}
.app-container.show-menu .header-icon, .header.fade-in .header-icon {
    background-image:url('../../../public/logo_color.png');
}
</style>